﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NHibernate;
using DotNet.Common.NHibernateUtil;
using ZLCMS.Data.Model;
namespace ZLCMS.Web.Wap.Member
{
    public partial class MessageDetail : ZLCMS.Web.Wap.Code.MemberPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (ISession session = SessionFactoryHelper.CreateSession())
            {
                MemberMsgInfo msg = session.Get<MemberMsgInfo>(Int32.Parse(Request["id"]));
                if (msg.MemberAccount != CurrentMemberAccount)
                {
                    Server.Transfer("/wap/member/messageindex.aspx");
                }
                else if(msg.Status == "0")
                {
                    msg.Status = "1";
                    msg.ReadTime = DateTime.Now;
                    session.Update(msg);
                    session.Flush();
                }
                if (!string.IsNullOrEmpty(msg.MsgUrl))
                {
                    Response.Redirect(msg.MsgUrl);
                }
                else
                {
                    Response.Redirect("/wap/member/messagelist.aspx?k=" + msg.Kind);
                }
            }
        }
    }
}